import mockApi from "@/api/mockApi";

export default class facilityMaintenanceRecordApi {
  static facilityMaintenanceRecords = [
    {id: 1, facilityId: 1, facilityName: '充电应急灯', maintenanceStartDate: '2024-02-02 08:30:00', maintenanceEndDate: '2024-02-02 18:00:00', staffId: 1, staffName: '赵六', remark: '一切正常', createTime: '2024-01-01 12:12:12'},
    {id: 2, facilityId: 2, facilityName: '高空摄像头', maintenanceStartDate: '2024-03-03 08:30:00', maintenanceEndDate: '2024-03-03 18:00:00', staffId: 2, staffName: '张三', remark: '一切正常', createTime: '2024-02-02 12:12:12'},
    {id: 3, facilityId: 3, facilityName: '顶楼换气扇', maintenanceStartDate: '2024-04-04 08:30:00', maintenanceEndDate: '2024-04-04 18:00:00', staffId: 3, staffName: '李四', remark: '一切正常', createTime: '2024-03-03 12:12:12'},
    {id: 4, facilityId: 4, facilityName: '大厅电风扇', maintenanceStartDate: '2024-05-05 08:30:00', maintenanceEndDate: '2024-05-05 18:00:00', staffId: 4, staffName: '王五', remark: '一切正常', createTime: '2024-04-04 12:12:12'}
  ]

  static async save (params) {
    console.log('facilityMaintenanceRecordApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('facilityMaintenanceRecordApi find params', params)
    const response = await mockApi.queryPageSuccessfully(facilityMaintenanceRecordApi.facilityMaintenanceRecords)
    return response.data
  }

  static async findById (id) {
    console.log('facilityMaintenanceRecordApi findById id', id)
    let target = {}
    for (let a of facilityMaintenanceRecordApi.facilityMaintenanceRecords) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('facilityMaintenanceRecordApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}